import req from "./api.js";

/**
 * @return  获取微信配置信息
 */
export const wxInfo = (url = window.location.href) =>
  req("/api/wxconfig", {
    url,
  });

/**
 * @return  获取时间列表
 */

export const getDate = () =>
  req("/api/ticket/calendar", {
    p: "wx",
  });

/**
 * @return  获取团体时间列表
 */

export const getTeamDate = () => req("/api/teamticket/calendar", {});

/**
 * @return  我的优惠券
 * @params{coupon_type} 优惠券使用范围 1 => '活动',2 => '景区门票',3 => '商品',默认获取所有
 * @params{use_description}优惠券状态 0 可使用 1 已失效，默认获取全部
 */
export const CouponMyCoupon = (coupon_type, use_description) =>
  req("/api/coupon/my_coupon", {
    coupon_type,
    use_description,
  });

/**
 * @return  散客参观须知
 */

export const pertextTip = () => req("/api/ticket/text_tip", {});

/**
 * 散客预约
 */
export const ticketorder = (data) => req("/api/ticketorder", data, "POST");

/**
 * 散客预约详情
 */
export const perOrderDetail = (torder_id) =>
  req("/api/my/ticketorder/detail", {
    torder_id,
  });

/**
 * 支付接口
 * torder_id订单id
 * payment_id支付类型 1、微信2、微信小程序4、支付宝
 */
export const payTicket = (torder_id, payment_id) =>
  req(
    "/api/ticketorder/pay",
    {
      torder_id,
      payment_id,
    },
    "POST"
  );

/**
 * 订单状态
 * torder_id订单id
 */
export const perOrderStatus = (torder_id) =>
  req("/api/my/ticketorder/order_status", {
    torder_id,
  });

/**
 * @return  团体参观须知
 */

export const teamtextTip = () => req("/api/teamticket/text_tip", {});

/**
 * @return  预约团体门票
 */
export const teamticketorder = (data) =>
  req("/api/teamticketorder", data, "POST");

/**
 * @return  我的门票
 * page 当前页码
 * limit 每页数量
 */

export const myTicketorder = (page, limit) =>
  req("/api/my/ticketorder", {
    page,
    limit,
  });

/**
 * @return  个人门票预约详情
 */
export const myTicketDetail = (torder_id) =>
  req("/api/my/ticketorder/detail", {
    torder_id,
  });

/**
 * @return  团队门票预约详情
 */
export const myTeamTicketDetail = (torder_id) =>
  req("/api/my/teamticketorder/detail", {
    torder_id,
  });

/**
 * @return  取消订单
 */
export const cancelTicket = (torder_id) =>
  req("/api/ticketorder/cancel", {
    torder_id,
  });

/**
 * @return  团队退票
 */
export const refundTeamticketorder = (torder_id) =>
  req(
    "/api/teamticketorder/refund",
    {
      torder_id,
    },
    "POST"
  );

/**
 * @return  个人退票
 */
export const refundTicketorder = (titem_ids) =>
  req(
    "/api/ticketorder/refund",
    {
      titem_ids,
    },
    "POST"
  );

/**
 * @return  团体参观须知
 */

export const getCardTypeLists = () => req("/api/get_card_type", {});
